import { Module } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';

import { AuthService } from './app.service';
import { AppStrategy } from './app.strategy';
import { ConfigService } from '@nestjs/config';
import { IConfig } from 'src/config/config';

@Module({
	imports: [
		PassportModule,
		JwtModule.registerAsync({
			useFactory: async (configService: ConfigService<IConfig>) =>{
				return {
					secret: configService.get<IConfig['jwt']>('jwt').secret,
					signOptions: { expiresIn: configService.get<IConfig['jwt']>('jwt').expiresIn },
				}
			}
		}),
	],
  	providers: [AuthService,AppStrategy],
	exports: [AuthService],
})
export class AuthModule {}
